package jsp;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 石小俊
 * @date 2023年07月03日 9:07
 */
@WebServlet("/show/*")
public class ShowServlet extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uri = request.getRequestURI();
        System.out.println("uri:"+uri);

        String contextPath = request.getContextPath();
        System.out.println("contextPath:"+contextPath);

        String servletPath = request.getServletPath();
        System.out.println("servletPath:"+servletPath);

        String path = uri.substring((contextPath+servletPath).length());
        System.out.println("path:"+path);

        String msg = (String) getServletContext().getAttribute("msg");
        System.out.println("application中存储的数据:"+msg);

        request.getRequestDispatcher("/WEB-INF"+path+".jsp").forward(request,response);
    }
}
